package homework;

public class FriendlyGame {
    public static void main(String[] args) {
        Racer r = new Racer("兔子",100,10000);
        Racer t = new Racer("乌龟",1000,1000);

        r.start();
        t.start();

        //让r和t线程都结束了，才能继续main
        try {
            r.join();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        try {
            t.join();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        System.out.println("兔子用时：" + r.getTime());
        System.out.println("乌龟用时：" + t.getTime());
        if(r.getTime() < t.getTime()){
            System.out.println("兔子赢");
        }else if(r.getTime() > t.getTime()){
            System.out.println("乌龟赢");
        }else{
            System.out.println("平局");
        }
    }
}
